import React, { useState, useEffect } from 'react';
import { Space, Switch, Table, Tag } from 'antd';
import type { ColumnsType } from 'antd/es/table';
import axios from 'axios';
import { getsandList } from '@/api/building'
import { use } from 'echarts';
import { Tabs } from 'antd';
import type { TabsProps } from 'antd';
const onChange = (key: string) => {
    console.log(key);
};

const items: TabsProps['items'] = [
    {
        key: '1',
        label: `Tab 1`,
        children: `Content of Tab Pane 1`,
    },
    {
        key: '2',
        label: `Tab 2`,
        children: `Content of Tab Pane 2`,
    },
    {
        key: '3',
        label: `Tab 3`,
        children: `Content of Tab Pane 3`,
    },
];
interface DataType {
    key: string;
    name: string;
    age: number;
    address: string;
    tags: string[];
}

const columns: ColumnsType<DataType> = [
    {
        title: '楼栋名称',
        dataIndex: 'title',
        key: 'title',
        render: (text) => <a>{text}</a>,
    },
    {
        title: '楼层数',
        dataIndex: 'house_type_id',
        key: 'house_type_id',
    },
    {
        title: '销售状态',
        dataIndex: 'sale_status',
        key: 'sale_status',
        render: (item) => {
            return item.sale_status ? "在售" : "售完"
        }
    },
    {
        title: '状态',
        key: 'tags',
        dataIndex: 'tags',
        render: (item) => {
            return <Switch checkedChildren="正常" unCheckedChildren="禁用" defaultChecked={item === 0 ? false : true}></Switch>
        }
    },
    {
        title: '操作',
        key: 'action',
        render: (_, record) => (
            <Space size="middle">
                <a>Invite {record.name}</a>
                <a>Delete</a>
            </Space>
        ),
    },
];

const data: DataType[] = [
    {
        key: '1',
        name: 'John Brown',
        age: 32,
        address: 'New York No. 1 Lake Park',
        tags: ['nice', 'developer'],
    },
    {
        key: '2',
        name: 'Jim Green',
        age: 42,
        address: 'London No. 1 Lake Park',
        tags: ['loser'],
    },
    {
        key: '3',
        name: 'Joe Black',
        age: 32,
        address: 'Sydney No. 1 Lake Park',
        tags: ['cool', 'teacher'],
    },
];
export default function sand() {
    const [data, useData] = useState([]);
    useEffect(() => {
        getsandList().then(res => {
            console.log(res.data.RECORDS, 'res');
            useData(res.data.RECORDS)
        })
    }, [])
    return (
        <><div>
            <Table columns={columns} dataSource={data} />
        </div><div>
                <Tabs defaultActiveKey="1" items={items} onChange={onChange} />
            </div></>

    );
}
